package com.lehecai.core.api.business;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangzq on 14-8-27.
 * 用户充值类别
 */
public class PaymentType extends IntegerBeanLabelItem {

    private static final long serialVersionUID = -530998782071935781L;

    private static final Logger logger = LoggerFactory.getLogger(PaymentType.class.getName());

    private static List<PaymentType> items = new ArrayList<PaymentType>();
    private static List<PaymentType> queryItems = new ArrayList<PaymentType>();

    protected PaymentType(String name, int value, boolean queryOnly) {
        super(PaymentType.class.getName(), name, value);

        queryItems.add(this);
        if (!queryOnly) {
            items.add(this);
        }
    }

    protected PaymentType(String name, int value) {
        this(name, value, false);
    }

    public static PaymentType getItem(int value){
        try {
            return (PaymentType) PaymentType.getResult(PaymentType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    public static List<PaymentType> getItems() {
        return items;
    }

    public static List<PaymentType> getItemsForQuery() {
        return queryItems;
    }

    public static final PaymentType ALL = new PaymentType("全部", -1, true);

    public static final PaymentType PAY_RECHARGE_TYPE_PLATFORM = new PaymentType("平台充值", 1);
    public static final PaymentType PAY_RECHARGE_TYPE_CYBER = new PaymentType("网银-储蓄卡信用卡", 2);
    public static final PaymentType PAY_RECHARGE_TYPE_DEPOSIT_NOCYBER = new PaymentType("无网银-储蓄卡", 3);
    public static final PaymentType PAY_RECHARGE_TYPE_CREDIT_NOCYBER = new PaymentType("无网银-信用卡", 4);

}
